<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单详情</title>
<link rel="stylesheet" href="css/order.css">
<link rel="stylesheet" href="css/common.css">
</head>

<body>
	<div class="orderBox">
		<div class="row">
			<p>
				<span>订单编号：</span> <span>${orderInfo.order.id }</span>
			</p>
			<p>
				<span>下单时间：</span> <span>${orderInfo.order.ordertimestr }</span>
			</p>
			<p>
				<i class="fa fa-trash-o" aria-hidden="true"></i>
			</p>
		</div>
		<div class="row">
			<p>
				<span>总金额：</span> <span class="activate_font">${orderInfo.order.money }</span>
			</p>
			<p>
				<span>支付方式：</span> <span>在线支付</span>
			</p>
		</div>
		<div class="row">
			<p>
				<span>收货人：</span> <span>${username }</span>
			</p>
		</div>
		<div class="row address">
			<p>
				<span>收货地址：</span> <span>${orderInfo.order.receiverinfo }</span>
			</p>
		</div>

		<!-- 未付款、未评价、已完成 -->
		<div class="row">
			<p>
				<span>订单状态：</span> <span class="activate_font">${orderInfo.order.state }</span>
			</p>
		</div>

		<div class="orderShop">
			<c:forEach items="${orderInfo.map }" var="entry">

				<ul class="orderShopBox">
					<li class="jcstart f333"><img
						src="${ pageContext.request.contextPath }${entry.key.imgurl}"
						alt=""><span class="mt12">${entry.key.name}</span></li>
					<li class="mt12">￥${entry.key.price}</li>
					<li class="mt12">×${entry.value}</li>
					<li class="f333 mt12">￥${entry.key.price * entry.value}</li>
				</ul>
			</c:forEach>
		</div>
	</div>

	<c:if test="${orderInfo.order.state == '未发货' }">
		<div class="btnArea">
			<div>
				<label for="">快递单号: </label> <input id="expressnumber" type="text"
					placeholder="请输入快递单号">
			</div>
			<button id="sendbtn">发货</button>
		</div>
	</c:if>
	
	
	
	<script src="js/jquery.min.js"></script>
	<script type="text/javascript">
		$("#sendbtn").click(function(){
			
			let expressnumber = $("#expressnumber").val();
			if(expressnumber == ""){
				alert("请输入发货单号");
				return;
			}
			
			$.post("${ pageContext.request.contextPath }/admin/confirmorder",{
				id: "${ orderInfo.order.id }",
				expressnumber: expressnumber
			},function(){
				alert("发货成功！");
				// 获得frame索引
		        var index = parent.layer.getFrameIndex(window.name);
		        //关闭当前frame
		        parent.location.reload();
		        parent.layer.close(index);
			})
		});
		
	</script>
</body>

</html>